package com.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.conf.Parameters;

public class ConnectionManager {
	private static ConnectionManager instance=null;
	private String host;
	private String port;
	private String dbName;
	private String usr;
	private String pwd;
	
	private ConnectionManager(){
		host = Parameters.DB_HOST;
		port = Parameters.DB_PORT;
		dbName = Parameters.DB_NAME;
		usr = Parameters.DB_USER;
		pwd = Parameters.DB_PASS;
	}
	
	public static ConnectionManager getInstance(){
		if(instance==null){
			instance=new ConnectionManager();
		}
		return instance;
	}
	
	public Connection getConnection(){
		String strConnection="jdbc:postgresql://"+host+":"+port+"/"+dbName;
		Connection conn=null;
		try {
			conn=DriverManager.getConnection(strConnection, usr, pwd);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}
	
}
